package com.weiwei.diancan.view;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.weiwei.diancan.R;

/**
 * Created by BMW on 2016/11/6.
 */
public class HuanZhuoDialog extends Dialog {

    private final TextView tv_cancel;
    private final TextView tv_update;
    private Activity context;
    private OnHZClick onHZClick;

    public HuanZhuoDialog(Activity context) {
        super(context, R.style.share_dialog);
        this.context = context;
        View v = LayoutInflater.from(context).inflate(R.layout.huanzhuo_dialog, null);
        tv_cancel = (TextView)v.findViewById(R.id.tv_cancel);
        tv_update = (TextView)v.findViewById(R.id.tv_update);

        tv_cancel.setOnClickListener(v1 -> cancel());
        tv_update.setOnClickListener(v1 -> {
            if(onHZClick!= null){
                onHZClick.onClick(v1);
            }
        });

        addContentView(v,
                new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                        LinearLayout.LayoutParams.WRAP_CONTENT));
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE |
                WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    }

    public void setOnHZClick(OnHZClick onHZClick) {
        this.onHZClick = onHZClick;
    }

    public interface OnHZClick{
        void onClick(View v);
    }

}
